/*
 * TCSS 422 Web Spider Project
 * Group Money: Al McKenzie, Michael Pitts, Taylor Zielske
 */
package model.domain;

import java.net.MalformedURLException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import model.URLInputCooker;

/**
 * This domain is a Place Holder until the domain's robots.txt can be parsed and 
 * checked for the rules regarding spidering the domain's web pages.
 * 
 * @author Michael Pitts
 * @version Oct 18, 2011
 */
public class PlaceHolderDomain extends AbstractDomain {
	
	/**
	 * The synchronized set containing the potential urls for this domain.
	 */
	final Set<String> my_potential_urls;
	
	/**
	 * Creates a new PlaceHolderDomain with the domain specified in string format.
	 * @param the_domain is the new domain.
	 * @param the_cooker is the URLInputCooker this program will use.
	 * @throws MalformedURLException if the given domain can not be used to check for
	 * a robots.txt file.
	 */
	public PlaceHolderDomain(final String the_domain, final URLInputCooker the_cooker) throws MalformedURLException {
		super(the_domain, the_cooker);
		my_potential_urls = Collections.synchronizedSet(new HashSet<String>());
		cookDomain(the_domain);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override public void addURL(final String the_url) {
		if (!my_potential_urls.contains(the_url)) {
			my_potential_urls.add(the_url);
		}
	}

	/**
	 * Gets all the potential URLSs stored by this domain (those not yet visited).
	 * @return a set of URLs that have not been processed yet by this domain.
	 */
	public Set<String> getPotential() {
		return Collections.unmodifiableSet(my_potential_urls);
	}

}
